Top 10k strings from MC Tutor (1985)(Hansoft)(Part 4 of 5).z80 in <root> / bin / z80 / software / Sinclair Spectrum Collection TOSEC.exe / Sinclair ZX Spectrum - Utilities & Educational / Sinclair ZX Spectrum - Utilities & Educational - [Z80] (TOSEC-v2007-01-01) /

Back to the directory listing

   4  i.e.    7 6 5 4 3 2 1 0   C
   4  LD HL,STORE
   3 DEFM "  ADD HL,HL
   3   LD A,(ST1)
   3   LD (ST3),A
   2 the number
   2  i.e.    C   7 6 5 4 3 2 1 0
   2  and Carry
   2  STORE BIN 69H
   2  INTRODUCTION
   2  A after   (HL)
   2  1 0 1 1 0 1 1 1   x   (183 dec.)
   2   LD (LREG),HL
   2   DJNZ LOOP3
   2   DJNZ LOOP2
   2   DJNZ LOOP1
   2   ADD HL,DE
   1 where x is any number and is unaffected bytne instruction.
   1 ve number we can holdin a single register,  using this notationis  0
   1 transfer (HL) to (DE), increment HL and DE, decrement BC, set PV flag if BC=0
   1 transfer (HL) to (DE), decrement HL, DE, and BC, set PV flag if BC=0
   1 the port whose number is in C
   1 the memory location (IY)
   1 the memory location (IX)
   1 the memory location (DE)
   1 the memory location (BC)
   1 the location (HL)
   1 the contents of the Accumulator is eXclusively ORed with
   1 the contents of
   1 the computer is HALTed until an interrupt comes to awake it again
   1 the carry flag is set, ie Set Carry Flag
   1 the carry flag is inverted, ie Compliment Carry Flag
   1 the alternative AF registers
   1 the accumulator is ComPared with
   1 the Stack Pointer
   1 the Refresh register
   1 the RETurn address is POPped from the stack
   1 the L register
   1 the Interrupt vector register
   1 the IY register
   1 the IX register
   1 the HL register
   1 the H register
   1 the Flag register
   1 the E register
   1 the DE register
   1 the D register
   1 the C register
   1 the BC, DE, HL registers are all EXchanged with the alternative set
   1 the BC register
   1 the B register
   1 the Accumulator is logically ORed with
   1 the Accumulator is logically ANDed with
   1 the Accumulator is NEGated, ie made negative
   1 the Accumulator
   1 the AF registers
   1 search from (HL) Incrementing BC bytes for data in Accumulator
   1 search from (HL) Decrementing BC bytes for data in Accumulator
   1 rotate the accumulator and carry Right
   1 rotate the Accumulator and carry Left
   1 rotate the Accumulator Right, shifting bit 0 into Carry
   1 rotate the Accumulator Left shifting bit 7 into Carry
   1 rotate Right Decimal contents of (HL) with least significant end of Accumulator
   1 rotate Left Decimal contents of (HL) with least significant end of Accumulator
   1 reSTart at address
   1 push the return address to stack and CALL
   1 port with the above number
   1 perform relative jump to
   1 perform jump to
   1 output from (HL) to port (C) increment HL, decrement B
   1 ouTput to port (C), from block from (HL) Decrementing HL for B bytes
   1 ouTput from (HL) to port (C) block from (HL) Incrementing for B bytes
   1 oUTput from (HL) to port (C) Decrement HL, decrement B
   1 memory location
   1 location (IY+offset)
   1 location (IX+offset)
   1 is loaded with
   1 is Shifted Right Logically, 0 is shifted into bit 7
   1 is Shifted Right Arithmetically, sign bit unchanged
   1 is Shifted Left Arithmetically, 0 is shifted into bit 0
   1 is Rotated Right, shifting bit 0 into Carry
   1 is Rotated Left shifting bit 7 into Carry
   1 is PUSHed onto the stack and the SP decremented by 2
   1 is POPped from the stack and the SP incremented by 2
   1 is INCremented by 1
   1 is EXchanged with
   1 is DECremented by 1
   1 invert all bits in A register, ie ComPLiment
   1 input data from
   1 if the Zero flag is set,
   1 if the Zero flag is not set,
   1 if the Sign flag is set, ie Minus,
   1 if the Sign flag is not set, ie Positive,
   1 if the Parity flag is sEt, ie Parity is Even,
   1 if the Parity flag is nOt set, ie Parity is Odd,
   1 if the Carry flag is set,
   1 if the Carry flag is not set,
   1 iNput into (HL) from port (C) increment HL, decrement B
   1 iNput into (HL) from port (C) Decrement HL, decrement B
   1 iNput from port (C), into block from (HL) Incrementing HL for B bytes
   1 iNput from port (C), into block from (HL) Decrementing HL for B bytes
   1 has taken from it the carry and
   1 has added to it the carry and
   1 has added to it
   1 enable Interrupts. NOT PERFORMED BY SIMULATOR.
   1 disable Interrupts. NOT PERFORMED BY SIMULATOR.
   1 decrement B, if zero continue, if Not Zero perform relative jump to
   1 decimal Adjust Accumulator
   1 compare (HL) with A, increment HL, decrement BC
   1 compare (HL) with A, decrement HL, and BC
   1 change Interrupt Mode to
   1 block transfer (BC) bytes starting at (HL) to (DE) incrementing
   1 block transfer (BC) bytes starting at (HL) to (DE) decrementing
   1 becomes  c 1 0 1 1 0 0 0   1  c= old Carry
   1 becomes  1 1 1 1 0 0 0 1   0   (-15 dec.)
   1 becomes  1 1 0 1 1 0 0 0   1   old bit 0=1 RR r, and RR (HL)  instructions  ( RotateRight )  is similar to RL  except that theshift around the 9 bits is to the right.
   1 becomes  1   0 1 1 0 0 0 1 c  c= old Carry
   1 becomes  1   0 1 1 0 0 0 1 1  old bit 7=1
   1 becomes  0 1 0 1 1 0 1 1   1   (91 dec.)
   1 becomes  0 0 1 1 0 0 0 1   0   (49 dec.)
   1 becomes  0    1 1 0 0 0 1 0 0  (196 dec.)
   1 and Carry are rotated Left
   1 and Carry are Rotated Right
   1 Three   types,   or   modes,  of  maskableinterrupts are available.
   1 The Accumulator has subtracted from it
   1 The  programmer  can arrange that maskableinterrupts  (MI) are ignored.   Within theZ80 there is a flag,  the interrupt enableflag,   that  can  be   set  and  cleared.Depending upon the state of this  flag  MIwill be accepted or ignored.
   1 Space missing
   1 RRD    Rotate Right Decimal (/10)
   1 RLD    Rotate Left Decimal  (*10)
   1 RETurn from Non-maskable interrupt: NOT PERFORMED BY SIMULATOR
   1 RETurn from Interrupt: NOT PERFORMED BY SIMULATOR
   1 RES N,(HL)
   1 Offset too big
   1 Offset missing
   1 Number too large
   1 Number missing
   1 No OPeration is performed, inspite of this it takes .
   1 No DEFB, or DEFW
   1 NOT DEFINED
   1 Missing space or ,
   1 Label too long
   1 Label not found
   1 Instruction unknown
   1 FLAGS$    Registers and Contents   % STAC
   1 Error after inst.
   1 EX5B:DEFM " LD HL,(STORE)
   1 DEFM "using addition to successively multiply by"
   1 DEFM "number held in the HL register pair by  10"
   1 DEFM "instruction  therefore  divide
   1 DEFM "becomes  0 1 0 1 1 0 1 1   1   (91 dec.)
   1 DEFM " into bit 7.
   1 DEFM " i.e.    7 6 5 4 3 2 1 0   C
   1 DEFM " The   SRL   or    Shift  Right  Logically"
   1 DEFM "  LD DE,(STORE)
   1 DEFM "  LD (STORE),HL
   1 DEFM "  ADD HL,DE
   1 Cursor keys, delete,  and auto-repeat are as standard. BREAK returns you to menu.
   1 Can only ADD IX/IY
   1 Bracket missing
   1 BIT N,(HL)
   1 All  these  instructions  affect  not onlythe Carry flag,  but the Zero,  Sign,  andParity flags.
   1 ADDRESS MACHINE CODE
   1 1   or  127  and   the  largestnegative number 1
   1 01 seconds to do it
   1 0 or -128.
   1 (viii)Return from interrupt (RETI).
   1 (vii) Enables interrupts
   1 (vi)  POP or EXchange registers.
   1 (v)   Disable interrupt if required.
   1 (iv)  Do interrupt routine.
   1 (ii ) PUSH or EXchange required registered(iii) Enables interrupt if required.
   1 (i)   Enter maskable interrupt, interrupts
   1 '^+^2^9^=^D^K^R^b^i^y^
   1  x   1 0 1 1 0 0 0 1
   1  x    0 1 1 0 0 0 1 0  (98 dec.)
   1  where N is the bit number 0-7SET N,(HL)
   1  to  thisfield.
   1  themultiplication and division of BCD numbersby ten.
   1  single  byte  instruction,  further
   1  since  number of "1"s is
   1  rotate r and carry left
   1  rotate r and Carry right
   1  rotate A right, carry duplicates
   1  rotate A left, carry duplicates 
   1  rotate A and carry left
   1  rotate A and Carry right
   1  operation.
   1  of the Accumulator.
   1  number of "1"s is 4
   1  interrupts are accepted.
   1  illustrate
   1  i.e. even.
   1  i.e.  -2  is equivalent to 254 etc.
   1  i.e.    C    7 6 5 4 3 2 1 0
   1  ectively  multiplies  a"
   1  contents  of  the  Accumulator   by
   1  complementing  and  adding 1 in one
   1  c   1 0 1 1 0 0 0 1
   1  are disabled at this time.
   1  after RRD
   1  after RLD
   1  Z    Zero
   1  You are trying to run code in allocated storage area. RET missing? Please EDIT 
   1  You are about to write to memory which   will affect your program. Please edit it.
   1  You are about to affect memory area not  allocated to you. Please edit program.   
   1  You  should  now  be  able  to  use otherassemblers  to  write  your own  programs.You  will  find  that  most  are  not   souser  friendly,  and  that  you  will  notbe  able  to   one  step  easily   throughinstructions.   Don't  despair.  You   canalways  return  to  this Tutor to simulateyour problem.
   1  When  performing   arithmetic  operationswhich  we  wish  to  interpret  within therange  -128 to +127,  the  Carry  flag  nolonger  signals  an out  of  range result.However another  flag, the overflow  (P/V)flag does. It is a "1" whenever the answeris outside the range  -128 to +127 and "0"within  the  range.  It  is  effectively acarry into bit 7 which would make the signbit incorrect.
   1  When  data is  transmitted from one placeto another, it is  possible  for errors toappear in the received  data.  Parity is asimple  way of  detecting single errors indata.  An  additional  bit is added to thedata  that  makes the total number of "1"sin  the  word  an  even  number.   If  thereceived word does not have an even numberof "1"s in it, then an error has occurred. In addition to this  even parity we coulduse odd parity,  where the word is made tohave an odd number of "1"s in it.
   1  We must return from an interrupt  routinewith the instruction  RETI  ( RETurn from Interrupt ) and not RET.
   1  We have so far treated information in theform of bytes or words. The Z80 does allowa  number  of  operations on  separate  orgroups of bits within one byte
   1  We  have  discussed  flags  as individualbits.  This is  the way they  are normallyused.  They are however actually stored inthe Z80 in a register, designated as  F orflag register.  The  flags are arranged asfollows :-
   1  To ensure that no  other interrupt occursduring this period and  therefore corruptsthe  register  contents  before  they  aresafe,  the  interrupts are disabled duringthese operations.
   1  This group of lessons will introduce  thethe idea of bit  manipulation and its  usein flag operations and in producing fastermethods of multiplication.
   1  This  example  uses   shifts  and  rotateinstructions  to   multiply   two  8   bitnumbers together.   One  number is rotatedto  examine  each bit in turn.   The othernumber is also  shifted and  added  to thetotal  if the  bit is set.  This method isfar quicker than the  method  of  repeatedaddition.
   1  This  example  is  a  simple  program  toillustrate   JP P,nn ,  and JP M,nn;  jumpif  positive and jump if minus.  Note thatthe   carry   is  still   operative,   andtherefore,  if you do not clear it  beforeADC  and SBC  the  later  jump  could   beunexpected.   In this example the carry isnot cleared, so  "look before you leap".
   1  This   completes  a   study  of  all  theinstructions available on the Z80 chip.
   1  These instructions are shift instructionsin which the bit that falls out one end ofthe register or memory  location is pushedback into  the  other end.  The Carry flageither forms  part of  the number  shiftedthereby   making   it   9  bits  long   orduplicates the state of the bit that  fellout  of the register.  There are thereforefour different types of rotate.
   1  These examples  illustrate the  operationof rotate instructions. Modify the initialcondition  of   the   location  STORE   toinvestigate their operation further.
   1  There is no reason for sticking to 8 bitsusing this method.  So long as the  numberof  bits  is  sufficient   and  the   mostsignificant bit is taken as  the sign  bitany size positive or negative  number  canbe represented.
   1  There are too many registers called up,  to display. Program will RUN as normal. 
   1  There  are  4  other  rotate instructionsthat  involve  the Accumulator  only. Theyare RLCA,  RLA,  RRCA,  and RRA.  They areidentical to RLC A, RL A, RRC A, and RR A,but only  affect  the  Carry flag, and aretwice as fast.
   1  There  are   three  logical  instructionsavailable  on  the  Z80.   They  are   allperformed  on a bit  by bit basis  betweenthe Accumulator and a number, register, orindirectly addressed memory location (HL).The result is left in the Accumulator.
   1  The two instructions that manipulate thisflag are
   1  The stack pointer is outside allocated   memory area. Please edit program.
   1  The sign and  parity flags can be used inall absolute ( NOT relative) jumps, calls,and returns.
   1  The program has been completed. You may  EDIT or reRUN. Exit by pressing BREAK.   
   1  The notation is :-
   1  The last  lessons deal with  instructionsthat allow the  outside world to interruptthe processor.
   1  The final set of lessons introduces  morespecialised  registers  and  instructions,and looks at the way the Z80 can talk withthe outside world.
   1  The examples illustrate the  operation ofthe logic  instructions.  The pupil shouldtest  his/her  understanding   further  bymodifying the contents of the 3 stores.
   1  The example shows the use of the  Refreshregister as a source of random numbers.
   1  The best way to describe these operationsis by example.  Both instructions  involvethe  Accumulator, and the  memory location(HL).  The  examples are in  Binary  CodedDecimal of course,  each  digit taking  upone  nibble  or  4 bits of the register ormemory location.
   1  The RRD instruction therefore divides thedecimal  number by 10.   It  can  also  bestrung together to  divide any  length BCDnumber  by 10.  The  low  digit of the twodigit  decimal  number can be  isolated bythis instruction.
   1  The F register sometimes forms a registerpair in  conjunction with the Accumulator.This   pair   is  called   AF.   The  onlyinstructions   previously   mentioned thatinvolve  this  register pair are  PUSH andPOP.
   1  The 3 shift instructions are  illustratedusing a fixed initial value in the  memorylocation STORE.
   1  The  three logical instructions AND,  OR,and XOR affect the Zero,  Sign, and Parityflags.   The Carry flag is reset to "0" inall cases. Thus the limitation of no ClearCarry instruction can be  perfomed  simplyby a logical instruction.
   1  The  instruction performed determines themeaning of the P/V flag.
   1  The  following  illustrates  the  way  inwhich  SET,  RES,  and  BIT can be used tomanipulate  individual  bits of a registeror memory location.
   1  The  Z80 has two instructions that may beused for these operations
   1  The  Z80  has  a flag  that is set if thenumber of  "1"s in a number is even.  Thisflag  is  in  fact  the  same flag  as theoverflow flag. It is termed the P/V flag.
   1  The  Z80  allows  us to  rotate  left andright nibbles as well as bits.
   1  The  Sign  and  overflow  flags  are alsooperative after ADC and SBC instruction onthe HL register. It reflects the  15th bit(or bit 7 of H register) .
   1  The  SRL r,  and   SRL (HL)  instructionsshift    the   register/memory    locationcontents right,  shifting  bit 0 into  theCarry flag and a "0" into bit 7.
   1  The  SRA r,  and   SRA (HL)  instructionsshift  the  register/memory  location (HL)right,  shifting bit 0 into the Carry flagand retaining the state of bit 7.
   1  The  SLA r,   and  SLA (HL)  instructionsshift  the  register/memory  contents leftshifting a "0"  into bit 0  and bit 7 intothe Carry flag.
   1  The   interruptautomatically  performs an  RST or CALL toaddress 0066H on completion of the currentinstructions.  The  routine  at  0066H  isperformed.  The instruction RETN or RETurnfrom    Non-maskable   interrupt   returnscontrol back to the interrupted routine atits next instruction .
   1  The   SRL   or    Shift  Right  Logicallyinstruction  therefore  divides a positivenumber by 2.  As with  SRA  the Carry flagindicates the half.
   1  Summary - shift instructions
   1  Summary - rotate instructions
   1  Summary - logical instructions
   1  Summary - decimal shifts
   1  Summary - bit manipulation
   1  STORE DEFW 254H
   1  STORE BIN 16
   1  ST3   BIN 0H
   1  ST2   BIN FH
   1  ST1   BIN 65H
   1  SRL r  divides +ve numbers 0 - 255 by 2
   1  SRA r  divides +ve and -ve numbers by 2
   1  SOURCE CODE   
   1  SLA r  multiplies +ve and -ve numbers
   1  SHIFT INSTRUCTIONS
   1  S and P/V FLAGS IN INSTRUCTIONS
   1  S    Sign
   1  Return to operating system
   1  RRD  Rotates the Decimal number Right
   1  RRC r,  RRC (HL)   instructions   (RotateRight Carry being duplicated )  is similarto  the  RLC  instruction  but is a  rightshift. Bit 0 is shifted into bit 7 and theCarry duplicates the old bit 0.
   1  RRC r    rotate r right, carry duplicates RRC (HL)
   1  RR instructions can be strung together todivide any length number by 2.
   1  ROTATE INSTRUCTIONS
   1  RLD  Rotates the Decimal number Left
   1  RLC r, and RLC (HL)  ( namely Rotate LeftCarry duplicating ),  shifts  the contentsleft,  bit 7 rotating into bit 0,  and theCarry duplicating the transferred bit.
   1  RLC r    rotate r left, carry duplicates  RLC (HL)
   1  RLC and RRC  instructions  are  useful insequentially   interrogating   the   wholecontents of  a register without corruptingits contents.
   1  RL r, and RL (HL)  Rotate  Left,  rotatesthe  register/memory   location  with  theCarry as a 9th bit, left.
   1  RL instructions can be strung together tomultiply any length number by 2, since theCarry is transferred between  repeated  RLinstructions.
   1  Program stopped. You may re-RUN, EDIT or press BREAK to return to menu.  
   1  Program has successfully assembled. Press RUN, EDIT, or exit by pressing BREAK. 
   1  Program counter has jumped to non-valid  address. EDIT or reRUN program.
   1  Press SPACE to select and ENTER to start
   1  Press SPACE to continue.
   1  Press RUN to begin example, EDIT to edit, and BREAK to return to menu.
   1  Please confirm disk loading required  Y/N
   1  Performing  a  similar calculation to theabove we can show that a register pair canrepresent a number in the  range +32767 to-32768.
   1  P/V   Parity and overflow
   1  One  Non-Maskable  Interrupt is availableon   the   Z80   chip.
   1  Of all the instructions described to dateonly  DAA treats it as a parity flag.  Allothers either have  no effect on it or useit as  an  overflow  flag.  All subsequentinstructions  either  have no effect on itor use it as parity.
   1  NUM2  DEFB 203
   1  NUM1  DEFB 212
   1  NEG   negates,  or  makes  negative,  the
   1  N    Subtract last
   1  MODE 2 is the most flexible,  the addressto  which  the  processor is forced is theindirect   address   held  in   a   memorylocation.   The  address  of  this  memorylocation  is  computed  from  the  contentof the  I  register,  which  provides  thehigh  byte  and  the  interrupting  devicewhich   provides  the  low   byte.   Sincethe   interrupt   routine   is   addressedindirectly  the   interrupts  are   termedvectored interrupts.
   1  MODE 1 is the  one  used by  the Sinclairsystem  ROM.  It is set by the instructionIM 1. This mode is similar in operation tothe  Non Maskable Interrupt   except  thatprocessor is  restarted  at  0038H insteadof 0066H as in the NMI.
   1  MODE 0 is set by  the  instruction  IM 0.This mode is the one described previously,where the RST n instruction is forced ontothe  data  highway to  fool the  processorinto performing the restart.
   1  Loading lessons 26-35
   1  Loading lessons 18-25
   1  Loading lessons 10-17
   1  Loading lessons 1-9
   1  Loading has been stopped
   1  Loading error
   1  Load further lessons from disk
   1  Load earlier lessons for revision
   1  LREG  BIN 0
   1  LOOP4 RR (HL)
   1  LOOP3 SRL (HL)
   1  LOOP3 RRC (HL)
   1  LOOP2 SLA (HL)
   1  LOOP2 RL (HL)
   1  LOOP2 ADC HL,BC
   1  LOOP1 SRA (HL)
   1  LOOP1 SBC HL,DE
   1  LOOP1 RLC (HL)
   1  LOOP  RR A
   1  LOOP  LD A,R
   1  LOOP  INC (HL)
   1  LOGICAL INSTRUCTIONS
   1  LESSONS  26 - 35
   1  LESSONS  18 - 25
   1  LD HL,ST2
   1  JP1   RET Z
   1  JP PO,nn  CALL PO,nn  RET PO  Parity  odd
   1  JP PE,nn  CALL PE,nn  RET PE  Parity even
   1  JP P,nn   CALL P,nn   RET P   Sign +ve
   1  JP M,nn   CALL M,nn   RET M   Sign -ve
   1  It is important to remember that the ZeroCarry, Sign, and overflow flags are alwaysoperative   after  an   8  bit  arithmeticinstruction or a 16 bit addition involvingthe  Carry.   Your  interpretation  of theresult determines which flag(s) you shouldbe interested in.
   1  Interrupts  fall  into  two  types,  Non-Maskable Interrupts (NMI)  and    MaskableInterrupts (MI). Maskable interrupt can beignored by the software, but NMIs cannot.
   1  In  the XOR ( eXclusive OR ) instruction,if the bit in the Accumulator is the  sameas   that   in  the   number ,  then   thecorresponding  bit  in the result will  be"0". If they are different it will be "1".Another  way   of   looking  at  the   XORinstruction is if one OR the other is  "1"but NOT both, the answer will be "1".
   1  In  the OR instruction,  if a bit in  theAccumulator  OR in  the other number is  a"1",  the corresponding bit in the  resultwill be "1". If not it will be "0"
   1  In  the  AND instruction, if a bit in theAccumulator  AND  other  number  are  "1",then the  corresponding bit in the  resultwill be "1". If not it will be "0"
   1  If  the  condition is not met the programwill  not  jump,  call  a  subroutine   orreturn.
   1  INTERRUPTS
   1  Hence the result of the  instruction  SLAor   Shift  Left  Arithmetically   is   tomultiply  the  positive  number by 2.  TheCarry indicates a result greater than 255.
   1  Hence interrupt routine take the form:-
   1  Hence    the   SRA    or    Shift   RightArithmetically  instruction  divides  bothpositive and negative numbers by 2.
   1  HREG  BIN 0
   1  H    Half carry
   1  Ex - using alternative set
   1  Ex - use of index registers
   1  Ex - sign and parity flags
   1  Ex - shift instructions
   1  Ex - rotate instructions 2
   1  Ex - rotate instructions 1
   1  Ex - logical instructions
   1  Ex - decimal rotation
   1  Ex - control instructions
   1  Ex - block transfer
   1  Ex - block search
   1  Ex - block I/O
   1  Ex - bit manipulation
   1  Ex - I/O instructions
   1  Entry   into   a    maskable    interruptautomatically disables interrupt.
   1  EXAMPLES OF SHIFT INSTRUCTIONS
   1  EXAMPLES OF ROTATE INSTRUCTIONS
   1  EXAMPLES OF LOGICAL INSTRUCTIONS
   1  EXAMPLES OF DECIMAL ROTATION
   1  EXAMPLES OF BIT MANIPULATION
   1  EXAMPLES OF +VE AND -VE NOTATION
   1  EXAMPLE USING ROTATE AND SHIFT
   1  EXAMPLE OF JUMP ON SIGN
   1  EI    Enable Interrupts.   After one more
   1  Disk V1.0 (c) HanSoft '85
   1  DI    Disable Interrupts immediately.
   1  DECIMAL ROTATE
   1  CPL   complements or inverts the contents
   1  C    Carry
   1  But  first  we shall look  further at theprocessors flags.
   1  BIT MANIPULATION
   1  As well as performing  OR  operations  onour  own flags, this instruction is usefulin   SETting  a  group  of  bits  in   theAccumulator.
   1  As can be  seen the  effect of  stringingtogether RLD instructions is to multiply adecimal number by 10. It is also useful inisolating the  high  digit  from  the  twodigit number.
   1  As  well  as  performing  ANDs on our ownflags,  this  instruction  is   useful  inmasking off areas of words,  or  resettinggroups of bits in the Accumulator.
   1  Apart  from  performing the  logical  XORfunction   on  our  own  flags   the   XORinstruction   is   useful   in   invertingindividual or groups of bits.
   1  Any   bit  in   a   register,  or  memorylocation using (HL),  can be SET to a "1".We  can also  RESet  any  bit to a "0". Totest the state of a bit in a  register, ormemory   location,   we   can    use   theinstruction BIT.   In this instruction theZero flag is set if  the  appropriate  bitis  "0"   and   reset  to  a  "0"  if  theappropriate  bit  is "1".   Hence  we  canproduce our  own flags to indicate  eventsand  then  act  upon  them   later in  ourprograms.
   1  An interrupt  originates from outside theprocessor,  requesting it to break off itscurrent  sequence of  operations  and dealwith some other function.
   1  An  interrupt  can  occur  at  any  time.It   follows   therefore   that   if   theinterrupted  program is  to  be  continued(i.e. be re entered),  the contents of anyregister that the  interrupt routine uses,must be stored or  pushed onto the  stack,and reloaded  or  POPped  from  the  stackbefore returning
   1  Although  these examples appear to be allpositive, they  can  be  viewed equally asnegative where appropriate  and  the  Signand  overflow  flags  observed  operating.Remember a  number above 128 is a negativenumber. Since all the negative numbers  inthe examples are small,  they  can be seenquickly   and   simply  be  converted   bysubtracting the number from 256.
   1  All the  above rotate  instructions  RLC,RL, RRC, and RR not only affect the  Carryflag  but  also  the Zero, Sign and Parityflags,  as  have  all  shift  instructionsdiscussed.
   1  AND A or OR A will  clear the carry  flagand not affect any registers.  XOR A  willclear Carry and the Accumulator.
   1  A Sign flag  (S) is  provided on the Z80.It  duplicates  the sign ( bit 7 ) of  theanswer after  any  arithmetic operation onthe Accumulator. The sign flag is  "0" fora positive result  and  "1" for a negativeresult.
   1  A  shift instruction is one in which  thebits of a  register or memory location aremoved   sideways,  left  or  right to  theadjacent bit.  As we shall see, this givesus   a   means   of  division  as well  asmultiplication.
   1  35.  Finale
   1  34.  Interrupts
   1  33.  Processor control instructions
   1  32.  Block I/O instructions
   1  31.  Block search instructions
   1  30.  Block tranfer instructions
   1  3 i.e. odd.
   1  29.  Block instructions - introduction
   1  28.  Input/Output instructions
   1  27.  The alternative set of registers
   1  26.  The index registers
   1  25.  Decimal rotating
   1  24.  Rotate instructions
   1  23.  Shift instructions
   1  22.  Logical instructions
   1  21.  Bit manipulation
   1  20.  S and P/V flags in instructions
   1  19.  The flag register and AF
   1  18.  Parity
   1  1 1 1 0 0 0 1 0   x   (-30 dec.)
   1  1 0 1 1 0 0 0 1   x
   1  1 0 1 1 0 0 0 1   c
   1  01010110   ORed together
   1  01010110   ANDed together
   1  01010110    XORed together
   1  0 1 1 0 0 0 1 0   x   (98 dec.)
   1  0 1 0 0 0 1 1 1  parity flag is set since
   1  0 0 1 1 0 1 0 0  parity flag is  not  set
   1  &    clears all  ENTER tabs to next line STOP  assembles   SPACE tabs in label are
   1   XOR (HL)
   1   THE FLAG REGISTER AND AF REGISTER PAIR
   1   SET 6,(HL)
   1   RES 3,(HL)
   1   Loading error
   1   LD DE,FFFEH
   1   LD DE,33
   1   LD DE,(NUM2)
   1   LD A,(NUM1)
   1   LD (HL),A5H
   1   JR Z,LOOP
   1   JR NC,JP1
   1   JR LOOP1
   1   JP P,LOOP1
   1   JP M,LOOP2
   1   Error  found  during  assembly. Please  correct before running program.
   1   DJNZ LOOP4
   1   BIT 2,(HL)
   1   AND (HL)
   1    GOOD  LUCK  and HAPPY  PROGRAMMING
   1    ASSEMBLED CODE   LABELS INSTRUCTIONS
   1     Enter the Z-80 simulator ?   Y/N